#include <stdio.h>
#include <string>
#include <string.h>
#include <mensajes.h>
#include <Server.h>
#include <SIGINT_Handler.h>
#include <SignalHandler.h>
#include <Logger.h>

int main(void) {
	Logger* log = Logger::getInstance();
	log->enabled(true);
	log->log(INFO, "[Server] Servidor iniciado");
	Server servidor;
	SIGINT_Handler sigint_handler;
	log->log(INFO, "[Server] Registro handler");
	SignalHandler::getInstance()->registrarHandler( SIGINT, &sigint_handler);

	while (sigint_handler.getGracefulQuit() == 0) {
		log->log(INFO, "[Server] Empiezo a escuchar solicitudes");
		servidor.run();
	}

	log->log(INFO, "[Server] Server finalizado");
	servidor.end();

	SignalHandler::destruir();

	return 0;
}
